package com.example.playmusic;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ArrayAdapterList extends BaseAdapter {
	private Context context;
	private List<ObjectSong> list;
	private String tag = "21106";

	public ArrayAdapterList(Context context, List<ObjectSong> list) {
		this.context = context;
		this.list = list;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder = null;
		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
		if (convertView == null) {
			convertView=(View)inflater.inflate(R.layout.list_items, null);
			holder = new ViewHolder();
			holder.txtName =(TextView)convertView.findViewById(R.id.name);
			convertView.setTag(holder);
		}
		else
		{
			holder=(ViewHolder)convertView.getTag();
		}
		ObjectSong items= (ObjectSong)getItem(position);
		holder.txtName.setText(items.getName());
		return convertView;
	}

	private class ViewHolder {
		TextView txtName;

	}

}
